package com.lion.ball.modules.orderfood.service.assistants.converters;

import java.sql.Timestamp;
import com.lion.common.base.utils.ConvertUtil;
import com.lion.common.base.utils.DbUtil;
import com.lion.common.spring.annotations.DataConverter;
import com.lion.common.spring.business.base.BaseConverter;
import com.lion.utils.TimeUtil;
import com.lion.ball.modules.orderfood.domain.entity.OfdOrderEntity;
import com.lion.ball.modules.orderfood.web.model.params.create.OfdOrderCreateParam;
import com.lion.ball.modules.orderfood.web.model.params.update.OfdOrderUpdateParam;
import com.lion.ball.modules.orderfood.web.model.results.OfdOrderResult;

/**
 * @author Chris Chan
 * Create on 2025-10-18 13:33
 * Use for: 订单 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class OfdOrderConverter implements BaseConverter<
        OfdOrderEntity,
        OfdOrderCreateParam,
        OfdOrderUpdateParam,
        OfdOrderResult> {
    @Override
    public OfdOrderEntity fromParam(OfdOrderCreateParam param) {
        OfdOrderEntity entity = new OfdOrderEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public OfdOrderEntity fromUpdateParam(OfdOrderUpdateParam param) {
        OfdOrderEntity entity = ConvertUtil.convert(param, OfdOrderEntity.class);
        return entity;
    }

    @Override
    public OfdOrderResult toResult(OfdOrderEntity entity) {
        OfdOrderResult result = ConvertUtil.convert(entity,OfdOrderResult.class);
        return result;
    }
}